package com.yjq.programmer.controller.app;

import com.yjq.programmer.dto.CollectDTO;
import com.yjq.programmer.dto.MusicDTO;
import com.yjq.programmer.dto.ResponseDTO;
import com.yjq.programmer.service.ICollectService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author 杨杨吖
 * @QQ 823208782
 * @WX yjqi12345678
 * @create 2022-11-27 20:38
 */
@RestController("AppCollectController")
@RequestMapping("/app/collect")
public class CollectController {

    @Resource
    private ICollectService collectService;

    /**
     * 小程序添加音乐到收藏操作
     * @param collectDTO
     * @return
     */
    @PostMapping("/add")
    public ResponseDTO<Boolean> appAddMusicToCollect(@RequestBody CollectDTO collectDTO) {
        return collectService.addMusicToCollect(collectDTO);
    }


    /**
     * 小程序取消音乐收藏操作
     * @param collectDTO
     * @return
     */
    @PostMapping("/remove")
    public ResponseDTO<Boolean> appRemoveMusicFromCollect(@RequestBody CollectDTO collectDTO) {
        return collectService.removeMusicFromCollect(collectDTO);
    }

    /**
     * 小程序判断用户是否收藏某个音乐
     * @param collectDTO
     * @return
     */
    @PostMapping("/isCollect")
    public ResponseDTO<Boolean> appIsCollectMusic(@RequestBody CollectDTO collectDTO) {
        return collectService.isCollectMusic(collectDTO);
    }

    /**
     * 小程序根据用户id获取收藏数据
     * @param collectDTO
     * @return
     */
    @PostMapping("/getByUserId")
    public ResponseDTO<List<MusicDTO>> appGetCollectByUserId(@RequestBody CollectDTO collectDTO) {
        return collectService.getCollectByUserId(collectDTO);
    }


}
